<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>ActionDispatch::Routing::Mapper::Resources</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" href="../../../../css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../../css/main.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../../css/github.css" type="text/css" media="screen" />
<script src="../../../../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../../js/main.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>

</head>

<body>     
    <div class="banner">
        
            <span>Ruby on Rails v4.0.0</span><br />
        
        <h1>
            <span class="type">Module</span> 
            ActionDispatch::Routing::Mapper::Resources 
            
        </h1>
        <ul class="files">
            
            <li><a href="../../../../files/actionpack/lib/action_dispatch/routing/mapper_rb.html">actionpack/lib/action_dispatch/routing/mapper.rb</a></li>
            
        </ul>
    </div>
    <div id="bodyContent">
        <div id="content">
  
    <div class="description">
      
<p>Resource routing allows you to quickly declare all of the common routes for
a given resourceful controller. Instead of declaring separate routes for
your <code>index</code>, <code>show</code>, <code>new</code>,
<code>edit</code>, <code>create</code>, <code>update</code> and
<code>destroy</code> actions, a resourceful route declares them in a single
line of code:</p>

<pre>resources :photos</pre>

<p>Sometimes, you have a resource that clients always look up without
referencing an ID. A common example, /profile always shows the profile of
the currently logged in user. In this case, you can use a singular resource
to map /profile (rather than /profile/:id) to the show action.</p>

<pre>resource :profile</pre>

<p>It’s common to have resources that are logically children of other
resources:</p>

<pre>resources :magazines do
  resources :ads
end</pre>

<p>You may wish to organize groups of controllers under a namespace. Most
commonly, you might group a number of administrative controllers under an
<code>admin</code> namespace. You would place these controllers under the
<code>app/controllers/admin</code> directory, and you can group them
together in your router:</p>

<pre>namespace &quot;admin&quot; do
  resources :posts, :comments
end</pre>

<p>By default the <code>:id</code> parameter doesn’t accept dots. If you need
to use dots as part of the <code>:id</code> parameter add a constraint
which overrides this restriction, e.g:</p>

<pre>resources :articles, id: /[^\/]+/</pre>

<p>This allows any character other than a slash as part of your
<code>:id</code>.</p>

    </div>
  


  


  
  


  


  
    <!-- Method ref -->
    <div class="sectiontitle">Methods</div>
    <dl class="methods">
      
        <dt>C</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Resources.html#method-i-collection">collection</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>M</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Resources.html#method-i-match">match</a>,
              </li>
            
              
              <li>
                <a href="Resources.html#method-i-member">member</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>N</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Resources.html#method-i-namespace">namespace</a>,
              </li>
            
              
              <li>
                <a href="Resources.html#method-i-nested">nested</a>,
              </li>
            
              
              <li>
                <a href="Resources.html#method-i-new">new</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>R</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Resources.html#method-i-resource">resource</a>,
              </li>
            
              
              <li>
                <a href="Resources.html#method-i-resources">resources</a>,
              </li>
            
              
              <li>
                <a href="Resources.html#method-i-resources_path_names">resources_path_names</a>,
              </li>
            
              
              <li>
                <a href="Resources.html#method-i-root">root</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>S</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Resources.html#method-i-set_member_mappings_for_resource">set_member_mappings_for_resource</a>,
              </li>
            
              
              <li>
                <a href="Resources.html#method-i-shallow">shallow</a>,
              </li>
            
              
              <li>
                <a href="Resources.html#method-i-shallow-3F">shallow?</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>U</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Resources.html#method-i-using_match_shorthand-3F">using_match_shorthand?</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>W</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Resources.html#method-i-with_exclusive_scope">with_exclusive_scope</a>,
              </li>
            
              
              <li>
                <a href="Resources.html#method-i-with_scope_level">with_scope_level</a>
              </li>
            
          </ul>
        </dd>
      
    </dl>
  

  



  

    

    

    
      <!-- Section constants -->
      <div class="sectiontitle">Constants</div>
      <table border='0' cellpadding='5'>
        
          <tr valign='top'>
            <td class="attr-name">VALID_ON_OPTIONS</td>
            <td>=</td>
            <td class="attr-value">[:new, :collection, :member]</td>
          </tr>
          
            <tr valign='top'>
              <td>&nbsp;</td>
              <td colspan="2" class="attr-desc"><p><a href="Resources.html#CANONICAL_ACTIONS">CANONICAL_ACTIONS</a> holds all
actions that does not need a prefix or a path appended since they fit
properly in their scope level.</p></td>
            </tr>
          
        
          <tr valign='top'>
            <td class="attr-name">RESOURCE_OPTIONS</td>
            <td>=</td>
            <td class="attr-value">[:as, :controller, :path, :only, :except, :param, :concerns]</td>
          </tr>
          
            <tr valign='top'>
              <td>&nbsp;</td>
              <td colspan="2" class="attr-desc"></td>
            </tr>
          
        
          <tr valign='top'>
            <td class="attr-name">CANONICAL_ACTIONS</td>
            <td>=</td>
            <td class="attr-value">%w(index create new show update destroy)</td>
          </tr>
          
            <tr valign='top'>
              <td>&nbsp;</td>
              <td colspan="2" class="attr-desc"></td>
            </tr>
          
        
          <tr valign='top'>
            <td class="attr-name">RESOURCE_METHOD_SCOPES</td>
            <td>=</td>
            <td class="attr-value">[:collection, :member, :new]</td>
          </tr>
          
            <tr valign='top'>
              <td>&nbsp;</td>
              <td colspan="2" class="attr-desc"></td>
            </tr>
          
        
          <tr valign='top'>
            <td class="attr-name">RESOURCE_SCOPES</td>
            <td>=</td>
            <td class="attr-value">[:resource, :resources]</td>
          </tr>
          
            <tr valign='top'>
              <td>&nbsp;</td>
              <td colspan="2" class="attr-desc"></td>
            </tr>
          
        
      </table>
    


    


    <!-- Methods -->
        
      <div class="sectiontitle">Instance Public methods</div>
      
        <div class="method">
          <div class="title method-title" id="method-i-collection">
            
              <b>collection</b>()
            
            <a href="Resources.html#method-i-collection" name="method-i-collection" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>To add a route to the collection:</p>

<pre>resources :photos do
  collection do
    get 'search'
  end
end</pre>

<p>This will enable <a href="../../../Rails.html">Rails</a> to recognize paths
such as <code>/photos/search</code> with GET, and route to the search
action of <code>PhotosController</code>. It will also create the
<code>search_photos_url</code> and <code>search_photos_path</code> route
helpers.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-collection_source')" id="l_method-i-collection_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/29d5c2c7939f4e7d5fdb304e328626351c8ada68/actionpack/lib/action_dispatch/routing/mapper.rb#L1276" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-collection_source" class="dyn-source">
                <pre><span class="ruby-comment"># File actionpack/lib/action_dispatch/routing/mapper.rb, line 1276</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">collection</span>
  <span class="ruby-keyword">unless</span> <span class="ruby-identifier">resource_scope?</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-string">&quot;can't use collection outside resource(s) scope&quot;</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">with_scope_level</span>(<span class="ruby-value">:collection</span>) <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">scope</span>(<span class="ruby-identifier">parent_resource</span>.<span class="ruby-identifier">collection_scope</span>) <span class="ruby-keyword">do</span>
      <span class="ruby-keyword">yield</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-match">
            
              <b>match</b>(path, *rest)
            
            <a href="Resources.html#method-i-match" name="method-i-match" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>match ‘path’ =&gt; ‘controlleraction’ match ‘path’, to: ‘controlleraction’
match ‘path’, ‘otherpath’, on: :member, via: :get</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-match_source')" id="l_method-i-match_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/29d5c2c7939f4e7d5fdb304e328626351c8ada68/actionpack/lib/action_dispatch/routing/mapper.rb#L1367" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-match_source" class="dyn-source">
                <pre><span class="ruby-comment"># File actionpack/lib/action_dispatch/routing/mapper.rb, line 1367</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">match</span>(<span class="ruby-identifier">path</span>, *<span class="ruby-identifier">rest</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">rest</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-constant">Hash</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">path</span>
    <span class="ruby-identifier">options</span>  = <span class="ruby-identifier">path</span>
    <span class="ruby-identifier">path</span>, <span class="ruby-identifier">to</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">find</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">_value</span><span class="ruby-operator">|</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">String</span>) }
    <span class="ruby-identifier">options</span>[<span class="ruby-value">:to</span>] = <span class="ruby-identifier">to</span>
    <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">path</span>)
    <span class="ruby-identifier">paths</span> = [<span class="ruby-identifier">path</span>]
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">options</span> = <span class="ruby-identifier">rest</span>.<span class="ruby-identifier">pop</span> <span class="ruby-operator">||</span> {}
    <span class="ruby-identifier">paths</span> = [<span class="ruby-identifier">path</span>] <span class="ruby-operator">+</span> <span class="ruby-identifier">rest</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">options</span>[<span class="ruby-value">:anchor</span>] = <span class="ruby-keyword">true</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value">:anchor</span>)

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:on</span>] <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-constant">VALID_ON_OPTIONS</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">options</span>[<span class="ruby-value">:on</span>])
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">&quot;Unknown scope #{on.inspect} given to :on&quot;</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">if</span> <span class="ruby-ivar">@scope</span>[<span class="ruby-value">:controller</span>] <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-ivar">@scope</span>[<span class="ruby-value">:action</span>]
    <span class="ruby-identifier">options</span>[<span class="ruby-value">:to</span>] <span class="ruby-operator">||=</span> <span class="ruby-node">&quot;#{@scope[:controller]}##{@scope[:action]}&quot;</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">paths</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">_path</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">route_options</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">dup</span>
    <span class="ruby-identifier">route_options</span>[<span class="ruby-value">:path</span>] <span class="ruby-operator">||=</span> <span class="ruby-identifier">_path</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">_path</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">String</span>)

    <span class="ruby-identifier">path_without_format</span> = <span class="ruby-identifier">_path</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-regexp">/\(\.:format\)$/</span>, <span class="ruby-string">''</span>)
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">using_match_shorthand?</span>(<span class="ruby-identifier">path_without_format</span>, <span class="ruby-identifier">route_options</span>)
      <span class="ruby-identifier">route_options</span>[<span class="ruby-value">:to</span>] <span class="ruby-operator">||=</span> <span class="ruby-identifier">path_without_format</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp">%r{^/}</span>, <span class="ruby-string">&quot;&quot;</span>).<span class="ruby-identifier">sub</span>(<span class="ruby-regexp">%r{/([^/]*)$}</span>, <span class="ruby-string">'#\1'</span>)
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">decomposed_match</span>(<span class="ruby-identifier">_path</span>, <span class="ruby-identifier">route_options</span>)
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-member">
            
              <b>member</b>()
            
            <a href="Resources.html#method-i-member" name="method-i-member" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>To add a member route, add a member block into the resource block:</p>

<pre>resources :photos do
  member do
    get 'preview'
  end
end</pre>

<p>This will recognize <code>/photos/1/preview</code> with GET, and route to
the preview action of <code>PhotosController</code>. It will also create
the <code>preview_photo_url</code> and <code>preview_photo_path</code>
helpers.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-member_source')" id="l_method-i-member_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/29d5c2c7939f4e7d5fdb304e328626351c8ada68/actionpack/lib/action_dispatch/routing/mapper.rb#L1299" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-member_source" class="dyn-source">
                <pre><span class="ruby-comment"># File actionpack/lib/action_dispatch/routing/mapper.rb, line 1299</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">member</span>
  <span class="ruby-keyword">unless</span> <span class="ruby-identifier">resource_scope?</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-string">&quot;can't use member outside resource(s) scope&quot;</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">with_scope_level</span>(<span class="ruby-value">:member</span>) <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">scope</span>(<span class="ruby-identifier">parent_resource</span>.<span class="ruby-identifier">member_scope</span>) <span class="ruby-keyword">do</span>
      <span class="ruby-keyword">yield</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-namespace">
            
              <b>namespace</b>(path, options = {})
            
            <a href="Resources.html#method-i-namespace" name="method-i-namespace" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>See <a
href="Scoping.html#method-i-namespace">ActionDispatch::Routing::Mapper::Scoping#namespace</a></p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-namespace_source')" id="l_method-i-namespace_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/29d5c2c7939f4e7d5fdb304e328626351c8ada68/actionpack/lib/action_dispatch/routing/mapper.rb#L1346" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-namespace_source" class="dyn-source">
                <pre><span class="ruby-comment"># File actionpack/lib/action_dispatch/routing/mapper.rb, line 1346</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">namespace</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">options</span> = {})
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">resource_scope?</span>
    <span class="ruby-identifier">nested</span> { <span class="ruby-keyword">super</span> }
  <span class="ruby-keyword">else</span>
    <span class="ruby-keyword">super</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-nested">
            
              <b>nested</b>()
            
            <a href="Resources.html#method-i-nested" name="method-i-nested" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-nested_source')" id="l_method-i-nested_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/29d5c2c7939f4e7d5fdb304e328626351c8ada68/actionpack/lib/action_dispatch/routing/mapper.rb#L1323" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-nested_source" class="dyn-source">
                <pre><span class="ruby-comment"># File actionpack/lib/action_dispatch/routing/mapper.rb, line 1323</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">nested</span>
  <span class="ruby-keyword">unless</span> <span class="ruby-identifier">resource_scope?</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-string">&quot;can't use nested outside resource(s) scope&quot;</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">with_scope_level</span>(<span class="ruby-value">:nested</span>) <span class="ruby-keyword">do</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">shallow?</span>
      <span class="ruby-identifier">with_exclusive_scope</span> <span class="ruby-keyword">do</span>
        <span class="ruby-keyword">if</span> <span class="ruby-ivar">@scope</span>[<span class="ruby-value">:shallow_path</span>].<span class="ruby-identifier">blank?</span>
          <span class="ruby-identifier">scope</span>(<span class="ruby-identifier">parent_resource</span>.<span class="ruby-identifier">nested_scope</span>, <span class="ruby-identifier">nested_options</span>) { <span class="ruby-keyword">yield</span> }
        <span class="ruby-keyword">else</span>
          <span class="ruby-identifier">scope</span>(<span class="ruby-ivar">@scope</span>[<span class="ruby-value">:shallow_path</span>], <span class="ruby-value">:as</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@scope</span>[<span class="ruby-value">:shallow_prefix</span>]) <span class="ruby-keyword">do</span>
            <span class="ruby-identifier">scope</span>(<span class="ruby-identifier">parent_resource</span>.<span class="ruby-identifier">nested_scope</span>, <span class="ruby-identifier">nested_options</span>) { <span class="ruby-keyword">yield</span> }
          <span class="ruby-keyword">end</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">scope</span>(<span class="ruby-identifier">parent_resource</span>.<span class="ruby-identifier">nested_scope</span>, <span class="ruby-identifier">nested_options</span>) { <span class="ruby-keyword">yield</span> }
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-new">
            
              <b>new</b>()
            
            <a href="Resources.html#method-i-new" name="method-i-new" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-new_source')" id="l_method-i-new_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/29d5c2c7939f4e7d5fdb304e328626351c8ada68/actionpack/lib/action_dispatch/routing/mapper.rb#L1311" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-new_source" class="dyn-source">
                <pre><span class="ruby-comment"># File actionpack/lib/action_dispatch/routing/mapper.rb, line 1311</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">new</span>
  <span class="ruby-keyword">unless</span> <span class="ruby-identifier">resource_scope?</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-string">&quot;can't use new outside resource(s) scope&quot;</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">with_scope_level</span>(<span class="ruby-value">:new</span>) <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">scope</span>(<span class="ruby-identifier">parent_resource</span>.<span class="ruby-identifier">new_scope</span>(<span class="ruby-identifier">action_path</span>(<span class="ruby-value">:new</span>))) <span class="ruby-keyword">do</span>
      <span class="ruby-keyword">yield</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-resource">
            
              <b>resource</b>(*resources, &amp;block)
            
            <a href="Resources.html#method-i-resource" name="method-i-resource" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Sometimes, you have a resource that clients always look up without
referencing an ID. A common example, /profile always shows the profile of
the currently logged in user. In this case, you can use a singular resource
to map /profile (rather than /profile/:id) to the show action:</p>

<pre>resource :geocoder</pre>

<p>creates six different routes in your application, all mapping to the
<code>GeoCoders</code> controller (note that the controller is named after
the plural):</p>

<pre>GET       /geocoder/new
POST      /geocoder
GET       /geocoder
GET       /geocoder/edit
PATCH/PUT /geocoder
DELETE    /geocoder</pre>

<h3 id="method-i-resource-label-Options">Options</h3>

<p>Takes same options as <code>resources</code>.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-resource_source')" id="l_method-i-resource_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/29d5c2c7939f4e7d5fdb304e328626351c8ada68/actionpack/lib/action_dispatch/routing/mapper.rb#L1079" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-resource_source" class="dyn-source">
                <pre><span class="ruby-comment"># File actionpack/lib/action_dispatch/routing/mapper.rb, line 1079</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">resource</span>(*<span class="ruby-identifier">resources</span>, &amp;<span class="ruby-identifier">block</span>)
  <span class="ruby-identifier">options</span> = <span class="ruby-identifier">resources</span>.<span class="ruby-identifier">extract_options!</span>.<span class="ruby-identifier">dup</span>

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">apply_common_behavior_for</span>(<span class="ruby-value">:resource</span>, <span class="ruby-identifier">resources</span>, <span class="ruby-identifier">options</span>, &amp;<span class="ruby-identifier">block</span>)
    <span class="ruby-keyword">return</span> <span class="ruby-keyword">self</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">resource_scope</span>(<span class="ruby-value">:resource</span>, <span class="ruby-constant">SingletonResource</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">resources</span>.<span class="ruby-identifier">pop</span>, <span class="ruby-identifier">options</span>)) <span class="ruby-keyword">do</span>
    <span class="ruby-keyword">yield</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">block_given?</span>

    <span class="ruby-identifier">concerns</span>(<span class="ruby-identifier">options</span>[<span class="ruby-value">:concerns</span>]) <span class="ruby-keyword">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:concerns</span>]

    <span class="ruby-identifier">collection</span> <span class="ruby-keyword">do</span>
      <span class="ruby-identifier">post</span> <span class="ruby-value">:create</span>
    <span class="ruby-keyword">end</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">parent_resource</span>.<span class="ruby-identifier">actions</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-value">:create</span>)

    <span class="ruby-identifier">new</span> <span class="ruby-keyword">do</span>
      <span class="ruby-identifier">get</span> <span class="ruby-value">:new</span>
    <span class="ruby-keyword">end</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">parent_resource</span>.<span class="ruby-identifier">actions</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-value">:new</span>)

    <span class="ruby-identifier">set_member_mappings_for_resource</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-resources">
            
              <b>resources</b>(*resources, &amp;block)
            
            <a href="Resources.html#method-i-resources" name="method-i-resources" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>In <a href="../../../Rails.html">Rails</a>, a resourceful route provides a
mapping between HTTP verbs and URLs and controller actions. By convention,
each action also maps to particular CRUD operations in a database. A single
entry in the routing file, such as</p>

<pre>resources :photos</pre>

<p>creates seven different routes in your application, all mapping to the
<code>Photos</code> controller:</p>

<pre>GET       /photos
GET       /photos/new
POST      /photos
GET       /photos/:id
GET       /photos/:id/edit
PATCH/PUT /photos/:id
DELETE    /photos/:id</pre>

<p><a href="Resources.html">Resources</a> can also be nested infinitely by
using this block syntax:</p>

<pre>resources :photos do
  resources :comments
end</pre>

<p>This generates the following comments routes:</p>

<pre>GET       /photos/:photo_id/comments
GET       /photos/:photo_id/comments/new
POST      /photos/:photo_id/comments
GET       /photos/:photo_id/comments/:id
GET       /photos/:photo_id/comments/:id/edit
PATCH/PUT /photos/:photo_id/comments/:id
DELETE    /photos/:photo_id/comments/:id</pre>

<h3 id="method-i-resources-label-Options">Options</h3>

<p>Takes same options as <code>Base#match</code> as well as:</p>
<dl class="rdoc-list label-list"><dt>:path_names
<dd>
<p>Allows you to change the segment component of the <code>edit</code> and
<code>new</code> actions. Actions not specified are not changed.</p>

<pre>resources :posts, path_names: { new: &quot;brand_new&quot; }</pre>

<p>The above example will now change /posts/new to /posts/brand_new</p>
</dd><dt>:path
<dd>
<p>Allows you to change the path prefix for the resource.</p>

<pre>resources :posts, path: 'postings'</pre>

<p>The resource and all segments will now route to /postings instead of /posts</p>
</dd><dt>:only
<dd>
<p>Only generate routes for the given actions.</p>

<pre>resources :cows, only: :show
resources :cows, only: [:show, :index]</pre>
</dd><dt>:except
<dd>
<p>Generate all routes except for the given actions.</p>

<pre>resources :cows, except: :show
resources :cows, except: [:show, :index]</pre>
</dd><dt>:shallow
<dd>
<p>Generates shallow routes for nested resource(s). When placed on a parent
resource, generates shallow routes for all nested resources.</p>

<pre>resources :posts, shallow: true do
  resources :comments
end</pre>

<p>Is the same as:</p>

<pre>resources :posts do
  resources :comments, except: [:show, :edit, :update, :destroy]
end
resources :comments, only: [:show, :edit, :update, :destroy]</pre>

<p>This allows URLs for resources that otherwise would be deeply nested such
as a comment on a blog post like
<code>/posts/a-long-permalink/comments/1234</code> to be shortened to just
<code>/comments/1234</code>.</p>
</dd><dt>:shallow_path
<dd>
<p>Prefixes nested shallow routes with the specified path.</p>

<pre>scope shallow_path: &quot;sekret&quot; do
  resources :posts do
    resources :comments, shallow: true
  end
end</pre>

<p>The <code>comments</code> resource here will have the following routes
generated for it:</p>

<pre>post_comments    GET       /posts/:post_id/comments(.:format)
post_comments    POST      /posts/:post_id/comments(.:format)
new_post_comment GET       /posts/:post_id/comments/new(.:format)
edit_comment     GET       /sekret/comments/:id/edit(.:format)
comment          GET       /sekret/comments/:id(.:format)
comment          PATCH/PUT /sekret/comments/:id(.:format)
comment          DELETE    /sekret/comments/:id(.:format)</pre>
</dd><dt>:shallow_prefix
<dd>
<p>Prefixes nested shallow route names with specified prefix.</p>

<pre>scope shallow_prefix: &quot;sekret&quot; do
  resources :posts do
    resources :comments, shallow: true
  end
end</pre>

<p>The <code>comments</code> resource here will have the following routes
generated for it:</p>

<pre>post_comments           GET       /posts/:post_id/comments(.:format)
post_comments           POST      /posts/:post_id/comments(.:format)
new_post_comment        GET       /posts/:post_id/comments/new(.:format)
edit_sekret_comment     GET       /comments/:id/edit(.:format)
sekret_comment          GET       /comments/:id(.:format)
sekret_comment          PATCH/PUT /comments/:id(.:format)
sekret_comment          DELETE    /comments/:id(.:format)</pre>
</dd><dt>:format
<dd>
<p>Allows you to specify the default value for optional <code>format</code>
segment or disable it by supplying <code>false</code>.</p>
</dd></dl>

<h3 id="method-i-resources-label-Examples">Examples</h3>

<pre class="ruby"><span class="ruby-comment"># routes call &lt;tt&gt;Admin::PostsController&lt;/tt&gt;</span>
<span class="ruby-identifier">resources</span> :<span class="ruby-identifier">posts</span>, <span class="ruby-keyword">module</span><span class="ruby-operator">:</span> <span class="ruby-string">&quot;admin&quot;</span>

<span class="ruby-comment"># resource actions are at /admin/posts.</span>
<span class="ruby-identifier">resources</span> :<span class="ruby-identifier">posts</span>, <span class="ruby-identifier">path</span><span class="ruby-operator">:</span> <span class="ruby-string">&quot;admin/posts&quot;</span>
</pre>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-resources_source')" id="l_method-i-resources_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/29d5c2c7939f4e7d5fdb304e328626351c8ada68/actionpack/lib/action_dispatch/routing/mapper.rb#L1237" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-resources_source" class="dyn-source">
                <pre><span class="ruby-comment"># File actionpack/lib/action_dispatch/routing/mapper.rb, line 1237</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">resources</span>(*<span class="ruby-identifier">resources</span>, &amp;<span class="ruby-identifier">block</span>)
  <span class="ruby-identifier">options</span> = <span class="ruby-identifier">resources</span>.<span class="ruby-identifier">extract_options!</span>.<span class="ruby-identifier">dup</span>

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">apply_common_behavior_for</span>(<span class="ruby-value">:resources</span>, <span class="ruby-identifier">resources</span>, <span class="ruby-identifier">options</span>, &amp;<span class="ruby-identifier">block</span>)
    <span class="ruby-keyword">return</span> <span class="ruby-keyword">self</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">resource_scope</span>(<span class="ruby-value">:resources</span>, <span class="ruby-constant">Resource</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">resources</span>.<span class="ruby-identifier">pop</span>, <span class="ruby-identifier">options</span>)) <span class="ruby-keyword">do</span>
    <span class="ruby-keyword">yield</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">block_given?</span>

    <span class="ruby-identifier">concerns</span>(<span class="ruby-identifier">options</span>[<span class="ruby-value">:concerns</span>]) <span class="ruby-keyword">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:concerns</span>]

    <span class="ruby-identifier">collection</span> <span class="ruby-keyword">do</span>
      <span class="ruby-identifier">get</span>  <span class="ruby-value">:index</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">parent_resource</span>.<span class="ruby-identifier">actions</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-value">:index</span>)
      <span class="ruby-identifier">post</span> <span class="ruby-value">:create</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">parent_resource</span>.<span class="ruby-identifier">actions</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-value">:create</span>)
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">new</span> <span class="ruby-keyword">do</span>
      <span class="ruby-identifier">get</span> <span class="ruby-value">:new</span>
    <span class="ruby-keyword">end</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">parent_resource</span>.<span class="ruby-identifier">actions</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-value">:new</span>)

    <span class="ruby-identifier">set_member_mappings_for_resource</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-resources_path_names">
            
              <b>resources_path_names</b>(options)
            
            <a href="Resources.html#method-i-resources_path_names" name="method-i-resources_path_names" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-resources_path_names_source')" id="l_method-i-resources_path_names_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/29d5c2c7939f4e7d5fdb304e328626351c8ada68/actionpack/lib/action_dispatch/routing/mapper.rb#L1054" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-resources_path_names_source" class="dyn-source">
                <pre><span class="ruby-comment"># File actionpack/lib/action_dispatch/routing/mapper.rb, line 1054</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">resources_path_names</span>(<span class="ruby-identifier">options</span>)
  <span class="ruby-ivar">@scope</span>[<span class="ruby-value">:path_names</span>].<span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">options</span>)
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-root">
            
              <b>root</b>(path, options={})
            
            <a href="Resources.html#method-i-root" name="method-i-root" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-root_source')" id="l_method-i-root_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/29d5c2c7939f4e7d5fdb304e328626351c8ada68/actionpack/lib/action_dispatch/routing/mapper.rb#L1443" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-root_source" class="dyn-source">
                <pre><span class="ruby-comment"># File actionpack/lib/action_dispatch/routing/mapper.rb, line 1443</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">root</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">options</span>={})
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">path</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">String</span>)
    <span class="ruby-identifier">options</span>[<span class="ruby-value">:to</span>] = <span class="ruby-identifier">path</span>
  <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">path</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>) <span class="ruby-keyword">and</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">empty?</span>
    <span class="ruby-identifier">options</span> = <span class="ruby-identifier">path</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-string">&quot;must be called with a path and/or options&quot;</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">if</span> <span class="ruby-ivar">@scope</span>[<span class="ruby-value">:scope_level</span>] <span class="ruby-operator">==</span> <span class="ruby-value">:resources</span>
    <span class="ruby-identifier">with_scope_level</span>(<span class="ruby-value">:root</span>) <span class="ruby-keyword">do</span>
      <span class="ruby-identifier">scope</span>(<span class="ruby-identifier">parent_resource</span>.<span class="ruby-identifier">path</span>) <span class="ruby-keyword">do</span>
        <span class="ruby-keyword">super</span>(<span class="ruby-identifier">options</span>)
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-keyword">super</span>(<span class="ruby-identifier">options</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-shallow">
            
              <b>shallow</b>()
            
            <a href="Resources.html#method-i-shallow" name="method-i-shallow" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-shallow_source')" id="l_method-i-shallow_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/29d5c2c7939f4e7d5fdb304e328626351c8ada68/actionpack/lib/action_dispatch/routing/mapper.rb#L1354" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-shallow_source" class="dyn-source">
                <pre><span class="ruby-comment"># File actionpack/lib/action_dispatch/routing/mapper.rb, line 1354</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">shallow</span>
  <span class="ruby-identifier">scope</span>(<span class="ruby-value">:shallow</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">:shallow_path</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@scope</span>[<span class="ruby-value">:path</span>]) <span class="ruby-keyword">do</span>
    <span class="ruby-keyword">yield</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-shallow-3F">
            
              <b>shallow?</b>()
            
            <a href="Resources.html#method-i-shallow-3F" name="method-i-shallow-3F" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-shallow-3F_source')" id="l_method-i-shallow-3F_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/29d5c2c7939f4e7d5fdb304e328626351c8ada68/actionpack/lib/action_dispatch/routing/mapper.rb#L1360" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-shallow-3F_source" class="dyn-source">
                <pre><span class="ruby-comment"># File actionpack/lib/action_dispatch/routing/mapper.rb, line 1360</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">shallow?</span>
  <span class="ruby-identifier">parent_resource</span>.<span class="ruby-identifier">instance_of?</span>(<span class="ruby-constant">Resource</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-ivar">@scope</span>[<span class="ruby-value">:shallow</span>]
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-using_match_shorthand-3F">
            
              <b>using_match_shorthand?</b>(path, options)
            
            <a href="Resources.html#method-i-using_match_shorthand-3F" name="method-i-using_match_shorthand-3F" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-using_match_shorthand-3F_source')" id="l_method-i-using_match_shorthand-3F_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/29d5c2c7939f4e7d5fdb304e328626351c8ada68/actionpack/lib/action_dispatch/routing/mapper.rb#L1403" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-using_match_shorthand-3F_source" class="dyn-source">
                <pre><span class="ruby-comment"># File actionpack/lib/action_dispatch/routing/mapper.rb, line 1403</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">using_match_shorthand?</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">options</span>)
  <span class="ruby-identifier">path</span> <span class="ruby-operator">&amp;&amp;</span> (<span class="ruby-identifier">options</span>[<span class="ruby-value">:to</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:action</span>]).<span class="ruby-identifier">nil?</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">path</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">%r{/[\w/]+$}</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
              
      <div class="sectiontitle">Instance Protected methods</div>
      
        <div class="method">
          <div class="title method-title" id="method-i-set_member_mappings_for_resource">
            
              <b>set_member_mappings_for_resource</b>()
            
            <a href="Resources.html#method-i-set_member_mappings_for_resource" name="method-i-set_member_mappings_for_resource" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-set_member_mappings_for_resource_source')" id="l_method-i-set_member_mappings_for_resource_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/29d5c2c7939f4e7d5fdb304e328626351c8ada68/actionpack/lib/action_dispatch/routing/mapper.rb#L1637" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-set_member_mappings_for_resource_source" class="dyn-source">
                <pre><span class="ruby-comment"># File actionpack/lib/action_dispatch/routing/mapper.rb, line 1637</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">set_member_mappings_for_resource</span>
  <span class="ruby-identifier">member</span> <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">get</span> <span class="ruby-value">:edit</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">parent_resource</span>.<span class="ruby-identifier">actions</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-value">:edit</span>)
    <span class="ruby-identifier">get</span> <span class="ruby-value">:show</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">parent_resource</span>.<span class="ruby-identifier">actions</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-value">:show</span>)
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">parent_resource</span>.<span class="ruby-identifier">actions</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-value">:update</span>)
      <span class="ruby-identifier">patch</span> <span class="ruby-value">:update</span>
      <span class="ruby-identifier">put</span>   <span class="ruby-value">:update</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">delete</span> <span class="ruby-value">:destroy</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">parent_resource</span>.<span class="ruby-identifier">actions</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-value">:destroy</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-with_exclusive_scope">
            
              <b>with_exclusive_scope</b>()
            
            <a href="Resources.html#method-i-with_exclusive_scope" name="method-i-with_exclusive_scope" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-with_exclusive_scope_source')" id="l_method-i-with_exclusive_scope_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/29d5c2c7939f4e7d5fdb304e328626351c8ada68/actionpack/lib/action_dispatch/routing/mapper.rb#L1519" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-with_exclusive_scope_source" class="dyn-source">
                <pre><span class="ruby-comment"># File actionpack/lib/action_dispatch/routing/mapper.rb, line 1519</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">with_exclusive_scope</span>
  <span class="ruby-keyword">begin</span>
    <span class="ruby-identifier">old_name_prefix</span>, <span class="ruby-identifier">old_path</span> = <span class="ruby-ivar">@scope</span>[<span class="ruby-value">:as</span>], <span class="ruby-ivar">@scope</span>[<span class="ruby-value">:path</span>]
    <span class="ruby-ivar">@scope</span>[<span class="ruby-value">:as</span>], <span class="ruby-ivar">@scope</span>[<span class="ruby-value">:path</span>] = <span class="ruby-keyword">nil</span>, <span class="ruby-keyword">nil</span>

    <span class="ruby-identifier">with_scope_level</span>(<span class="ruby-value">:exclusive</span>) <span class="ruby-keyword">do</span>
      <span class="ruby-keyword">yield</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">ensure</span>
    <span class="ruby-ivar">@scope</span>[<span class="ruby-value">:as</span>], <span class="ruby-ivar">@scope</span>[<span class="ruby-value">:path</span>] = <span class="ruby-identifier">old_name_prefix</span>, <span class="ruby-identifier">old_path</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-with_scope_level">
            
              <b>with_scope_level</b>(kind, resource = parent_resource)
            
            <a href="Resources.html#method-i-with_scope_level" name="method-i-with_scope_level" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-with_scope_level_source')" id="l_method-i-with_scope_level_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/29d5c2c7939f4e7d5fdb304e328626351c8ada68/actionpack/lib/action_dispatch/routing/mapper.rb#L1532" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-with_scope_level_source" class="dyn-source">
                <pre><span class="ruby-comment"># File actionpack/lib/action_dispatch/routing/mapper.rb, line 1532</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">with_scope_level</span>(<span class="ruby-identifier">kind</span>, <span class="ruby-identifier">resource</span> = <span class="ruby-identifier">parent_resource</span>)
  <span class="ruby-identifier">old</span>, <span class="ruby-ivar">@scope</span>[<span class="ruby-value">:scope_level</span>] = <span class="ruby-ivar">@scope</span>[<span class="ruby-value">:scope_level</span>], <span class="ruby-identifier">kind</span>
  <span class="ruby-identifier">old_resource</span>, <span class="ruby-ivar">@scope</span>[<span class="ruby-value">:scope_level_resource</span>] = <span class="ruby-ivar">@scope</span>[<span class="ruby-value">:scope_level_resource</span>], <span class="ruby-identifier">resource</span>
  <span class="ruby-keyword">yield</span>
<span class="ruby-keyword">ensure</span>
  <span class="ruby-ivar">@scope</span>[<span class="ruby-value">:scope_level</span>] = <span class="ruby-identifier">old</span>
  <span class="ruby-ivar">@scope</span>[<span class="ruby-value">:scope_level_resource</span>] = <span class="ruby-identifier">old_resource</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
                    </div>

    </div>
  </body>
</html>    